import request from '/@/utils/request'

export interface MenuForm {
  menu_id?: number
  parent_id: number
  name: string
  path: string
  component: string
  redirect: string
  title: string
  icon: string
  is_custom_svg: number
  type: number
  perms: string
  sort: number
  hidden: number
  no_keep_alive: number
  status: number
}

// 获取菜单列表
export function getMenuList(params?: any) {
  return request({
    url: '/admin/menu/getList',
    method: 'get',
    params,
  })
}

// 创建菜单
export function createMenu(data: MenuForm) {
  return request({
    url: '/admin/menu/doAdd',
    method: 'post',
    data,
  })
}

// 更新菜单
export function updateMenu(data: MenuForm) {
  return request({
    url: '/admin/menu/doEdit',
    method: 'post',
    data,
  })
}

// 删除菜单
export function deleteMenu(id: number) {
  return request({
    url: '/admin/menu/doDelete',
    method: 'post',
    data: { menu_id: id },
  })
} 